home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
Scene Storm
/
Scene Storm - Volume 1.iso
/
coding
/
asm
/
utils
/
cryptdevice
/
resetdev.c
< prev
Wrap
C/C++ Source or Header
|
1980-01-03
|
1KB
|
72 lines
/*
* resetdev.c
*
*/
#include <exec/types.h>
#include <exec/devices.h>
#include <exec/io.h>
#ifdef __SASC
#include <proto/exec.h>
int CXBRK(void) {return 0;}
#endif
#include <stdio.h>
#include <stdlib.h>
struct MsgPort *MPort = NULL;
struct IOStdReq *Req = NULL;
struct Device *Dev = NULL;
char *dev_name = "crypt.device";
main(int argc, char *argv[])
{
int unit;
int err = 10;
if(argc != 2 && argc != 3)
{
fprintf(stderr, "Usage: %s unitnumber [devicename]\n", argv[0]);
exit(10);
}
if(argc == 3) dev_name = argv[2];
unit = atoi(argv[1]);
if((MPort = CreatePort(0,0)) == NULL)
{
fprintf(stderr, "Can't create message port\n");
goto cleanexit;
}
if((Req = (struct IOStdReq *)CreateExtIO(MPort,
sizeof(struct IOStdReq))) == NULL)
{
fprintf(stderr, "Can't create IORequest\n");
goto cleanexit;
}
if(OpenDevice(dev_name, unit, Req, 0))
{
fprintf(stderr, "Can't open %s\n", dev_name);
goto cleanexit;
}
Dev = Req->io_Device;
Req->io_Command = CMD_RESET;
DoIO(Req);
err = 0;
cleanexit:
if(Dev) CloseDevice(Req);
if(Req) DeleteExtIO(Req);
if(MPort) DeletePort(MPort);
exit(err);
}